#include <iostream>
#include <string>
#define MAXN 100
using namespace std;
int dp[MAXN][MAXN];
string s, t;
void solve();
int main() {
    cin >> s >> t;
    solve();
}

void solve() {
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j + 1]);
        }
    }
    cout << dp[s.size()][t.size()] << endl;
    return;
}